// var gio = require("service/gio-minp.js").default;
// version 是你的小程序的版本号, 发版时请调整
// gio('init', '98db34f72a1e8c40', 'wx4175126b5f2a68dc', { version: '2.0.1.66' });

//app.js
var http = require('service/http.js');
var req = require('service/dl.js');
var storage = require('service/storage');
var fmt = require('service/fmt.js');

const updateManager = wx.getUpdateManager();

var app = {
    globalData: {
        userInfo: null,
        uid: null,
        openid: null,
        token: null,
        accesstoken:null,
        imgUrl: 'https://www.dianlinet.com',

        // ceshi: "https://www.dianlinet.com/westore",
         ceshi: "https://cs.dianlinet.cn/westore",
        //  ceshi: "http://192.168.1.127:84/westore",

        // invalid : null
        // domain:'https://cs.dianlinet.cn',
        domain:'https://www.dianlinet.com',
    },

    onLaunch: function () {
        //判断token是否存在
            var accesstoken = wx.getStorageSync('accesstoken')
        if (accesstoken) {
            console.log('111')
            console.log(wx.getStorageSync('uid'));
            this.globalData.uid = wx.getStorageSync('uid');
            this.globalData.openid = wx.getStorageSync('openid');
            this.globalData.token = wx.getStorageSync('token');
            this.globalData.accesstoken = wx.getStorageSync('accesstoken');
            // console.log(wx.getStorageSync('token'));
        }
        storage.load(req);
        wx.removeStorageSync('browse');
        updateManager.onCheckForUpdate(function (res) {
            // 请求完新版本信息的回调
            console.log(res.hasUpdate)
        });
        updateManager.onUpdateReady(function () {
            updateManager.applyUpdate();
        })

        let extConfig = wx.getExtConfigSync? wx.getExtConfigSync(): {} ;
        console.log('-------------');
        console.log(extConfig);
        if(extConfig.westore != null) {
            req.registerApiHost(extConfig.westore);
        } else {
            req.registerApiHost(app.globalData.ceshi);
        }

    },

    onShow(){
        let extConfig = wx.getExtConfigSync? wx.getExtConfigSync(): {} ;
        console.log('----+++++-----');
        console.log(extConfig);
        if(extConfig.westore != null) {
            req.registerApiHost(extConfig.westore);
        } else {
            req.registerApiHost(app.globalData.ceshi);
        }
    },

    func: req,

    funct: {
        req: http.req
    },

    storage: storage,

    fmt: fmt,
    //当前供应商ID
    sup_id: null

};

App(app);

